<?php

namespace app\api\controller;

use app\api\model\dealer\Bank;

/**
 * 提现银行卡管理
 * Class DealerBank
 * @package app\api\controller
 */
class DealerBank extends Controller
{
    /**
     * 提现银行卡列表
     * @return array
     * @throws \app\common\exception\BaseException
     * @throws \think\exception\DbException
     */
    public function lists()
    {
        $user = $this->getUser();
        $model = new Bank;
        $list = $model->getList($user['user_id']);
        return $this->renderSuccess([
            'list' => $list
        ]);
    }

    /**
     * 添加银行卡
     * @return array
     * @throws \app\common\exception\BaseException
     * @throws \think\exception\DbException
     */
    public function add()
    {
        $model = new Bank;
        if ($model->add($this->getUser(), $this->request->post(), $this->wxapp_id)) {
            return $this->renderSuccess([], '添加成功');
        }
        return $this->renderError($model->getError() ?: '添加失败');
    }


}
